<extend name="Layout:layout_edit" />
<block name="body_content_block">
    <form action="{:AddonU('MeetingRoom/item_edit_save')}" method="post" data-success-fn="show_reload_tip()">
        <table>
            <if condition="$isSuperAdmin">
                <th>租户ID：</th><td><select name="siteID" title="请选择租户" required data-url="{:AddonU('Admin/get_admin_json')}" data-value="{$data.siteID}"></select>
                <else/>
                <tr style="display: none;"><input type="hidden" name="siteID" value="{$loginData.siteID}"/></td></tr>
            </if>
            <tr>
                <th>会议号：</th><td>
                    <input type="text" class="easyui-textbox" name="exten" placeholder="请输入会议号" value="{$data.exten}" title="请填写会议号!" required data-url="{:AddonU('Status/cti_check_extension')}"/> <span style="color:#F00;"></span>
                </td></tr>
            <tr>
                <th>会议名称：</th><td>
                    <input type="text" class="easyui-textbox" name="description" placeholder="请输入会议名称" value="{$data.description}" title="请填写会议名称!" required/>
                </td></tr>
        </table>
        <input type="hidden" name="id" value="{$data.id}" />
    </form>
</block>
<block name="body_after_block">
    <script>
        if ($('input[name="id"]').val()) {
            $('input[name="exten"]').blur(function () {
                var $this = $(this);
                if (!$this.val()) {
                    return;
                }
                $.get($this.data('url'), {extension: $this.val()}, function (data) {
                    if (data.status) {
                        $this.next().text('');
                    } else {
                        $this.next().text(data.info);
                        $this.val('');
                    }
                })
            })
        }
        ajax_load_options({selector: 'select[name="siteID"]', def_option: '选择租户', func: afterSiteID});
        afterSiteID();
        function afterSiteID() {
            var val = $('select[name="siteID"]').val();
            if (!val) {
                val = '{$loginData.siteID}';
            }
        }
        $('select[name="siteID"]').change(function () {
            afterSiteID();
        })
    </script>
</block>